@model IEnumerable<UpdaterManagement.Models.Enterprise>

<nav aria-label="breadcrumb" class="breadcrumb-ace">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="/">首页</a></li>
        <li class="breadcrumb-item active">企业管理</li>
    </ol>
</nav>

<div class="page-header">
    <div class="d-flex justify-content-between align-items-center">
        <div>
            <h1 class="page-title">
                <i class="bi bi-buildings text-primary me-2"></i>企业管理
            </h1>
            <p class="page-subtitle">管理系统中的企业客户信息</p>
        </div>
        <a href="/Enterprise/Create" class="btn btn-ace-primary">
            <i class="bi bi-plus-circle me-2"></i>新增企业
        </a>
    </div>
</div>

<div class="row mb-4">
    <div class="col-xl-6 col-md-6">
        <div class="stat-card">
            <div class="stat-icon text-primary">
                <i class="bi bi-buildings"></i>
            </div>
            <div class="stat-number text-primary">@ViewBag.TotalCount</div>
            <div class="stat-label">总企业数</div>
        </div>
    </div>
    <div class="col-xl-6 col-md-6">
        <div class="stat-card">
            <div class="stat-icon" style="color: var(--ace-success);">
                <i class="bi bi-person-badge"></i>
            </div>
            <div class="stat-number" style="color: var(--ace-success);">@Model.GroupBy(e => e.Manager).Count()</div>
            <div class="stat-label">客户经理数</div>
        </div>
    </div>
</div>

@if (Model.Any())
{
    <div class="card-ace">
        <div class="card-header">
            <i class="bi bi-table me-2"></i>企业列表
            <span class="badge badge-ace-secondary ms-2">@ViewBag.TotalCount 个企业</span>
        </div>
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-ace mb-0">
                    <thead>
                        <tr>
                            <th>企业代码</th>
                            <th>企业名称</th>
                            <th>ERP编号</th>
                            <th>客户经理</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>
                                    <code class="text-primary">@item.Code</code>
                                </td>
                                <td>
                                    <strong class="text-dark">@item.Name</strong>
                                </td>
                                <td>
                                    <span class="badge badge-ace-info">@item.ErpNumber</span>
                                </td>
                                <td>
                                    <strong>@item.Manager</strong>
                                </td>
                                <td>
                                    <small class="text-muted">@item.CreatedTime.ToString("yyyy-MM-dd")</small>
                                </td>
                                <td>
                                    <div class="btn-group btn-group-sm">
                                        <a href="/Enterprise/Edit/@item.Id" class="btn btn-outline-primary btn-sm" title="编辑企业">
                                            <i class="bi bi-pencil"></i>
                                        </a>
                                        <form method="post" action="/Enterprise/Delete/@item.Id" class="d-inline">
                                            <button type="button" class="btn btn-outline-danger btn-sm" title="删除企业" 
                                                    onclick="showDeleteConfirm('@item.Name', this.form)">
                                                <i class="bi bi-trash"></i>
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
        
        <partial name="_Pagination" />
    </div>
}
else
{
    <div class="text-center py-5">
        <div class="mb-3">
            <i class="bi bi-buildings" style="font-size: 48px; color: #ccc;"></i>
        </div>
        <h5 class="text-muted">暂无企业数据</h5>
        <p class="text-muted">请点击上方按钮添加第一个企业</p>
        <a href="/Enterprise/Create" class="btn btn-ace-primary">
            <i class="bi bi-plus-circle me-2"></i>立即添加
        </a>
    </div>
}